#ifndef VIDEOANALYSISSYSTEM_VAS_UTILS_H
#define VIDEOANALYSISSYSTEM_VAS_UTILS_H

#include <string>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <thread>
#include <sys/time.h>
#include <execinfo.h>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_sinks.h>
#include <json/json.h>
#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs/legacy/constants_c.h>
#include <opencv2/imgproc/types_c.h>


namespace vas {
    const char LOGGER_NAME[] = "VasLogger";
    const char LOG_FILENAME[] = "vas.log";
#define VAS_INFO(msg) \
    spdlog::get(LOGGER_NAME) -> info(msg)             \
    // Info(msg, __FILE__, __LINE__, __FUNCTION__)

#define VAS_ERROR(msg) \
    spdlog::get(LOGGER_NAME) -> error(msg); \
    spdlog::dump_backtrace()                   \
    // Error(msg, __FILE__, __LINE__, __FUNCTION__)

    Json::Value StringToJson(const std::string &data);

    // generate random integer in [a, b]
    int RandomInt(int a, int b);

    // get the microsecond timestamp
    long GetCurrentTime();

    std::string GetFormatCurrentTime();

    std::string base64Encode(const unsigned char *Data, int DataByte);

    std::string base64Decode(const char *Data, int DataByte);

    cv::Mat Base64ToMat(std::string &base64_data);

    //imgType 包括png bmp jpg jpeg等opencv能够进行编码解码的文件
    std::string MatToBase64(const cv::Mat &img, std::string imgType = "jpg");

    void LoggerInit();

    void Info(const std::string &msg, const char *file, int line, const char *function);

    void Error(const std::string &msg, const char *file, int line, const char *function);

    std::string FileToString(const std::string &filename);

    std::string Banner();

}
#endif //VIDEOANALYSISSYSTEM_VAS_UTILS_H
